<!DOCTYPE HTML>
<html lang="en">
<head>
<title>IsLabel() - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The IsLabel function returns a non-zero number if the specified label exists in the script." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>IsLabel()</h1>

<p>Returns a non-zero number if the specified label exists in the script.</p>

<pre class="Syntax">TrueOrFalse := <span class="func">IsLabel</span>(LabelName)</pre>
<h2>Parameters</h2>
<dl>

  <dt>LabelName</dt>
  <dd><p>The name of a <a href="Gosub.htm">subroutine</a>, <a href="../Hotkeys.htm">hotkey</a>, or <a href="../Hotstrings.htm">hotstring</a> (do not include the trailing colon(s) in <em>LabelName</em>).</p></dd>

</dl>

<h2>Return Value</h2>
<p>This function returns a non-zero number if <em>LabelName</em> exists in the script.</p>

<h2>Remarks</h2>
<p>This function is useful to avoid runtime errors when specifying a dynamic label in commands such as <a href="Gosub.htm">Gosub</a>, <a href="Hotkey.htm">Hotkey</a>, <a href="Menu.htm">Menu</a>, and <a href="Gui.htm">Gui</a>.</p>
<h2>Related</h2>
<p><a href="../misc/Labels.htm">Labels</a></p>
<h2>Examples</h2>
<div class="ex" id="ExSubroutine">
<p><a href="#ExSubroutine">#1</a></p>
<pre>if IsLabel("Label")
    MsgBox, Subroutine exists
else
    MsgBox, Subroutine doesn't exist

Label:
return</pre>
</div>

<div class="ex" id="ExHotkey">
<p><a href="#ExHotkey">#2</a></p>
<pre>if IsLabel("^#h")
    MsgBox, Hotkey exists
else
    MsgBox, Hotkey doesn't exist

^#h::return</pre>
</div>

<div class="ex" id="ExHotstring">
<p><a href="#ExHotstring">#3</a></p>
<pre>if IsLabel("::btw")
    MsgBox, Hotstring exists
else
    MsgBox, Hotstring doesn't exist

::btw::by the way</pre>
</div>

</body>
</html>
